import { http } from "@/utils/http";
import type { AxiosResultDefault } from "./type";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};
// 字典
export const queryChildByTypeCodeAndItemValue = (data?: object) => {
  return http.request<AxiosResultDefault<Array<any>>>("post", `/account/api/v1/publish/dictItem/queryChildByTypeCodeAndItemValue`, {
    data
  });
};

//类型查询
export const queryReportType = (params?: object) => {
  return http.request("get", `/operation/api/v1/report/list/reportType`, {
    params
  });
};

// 交接人
export const userlistPage = (data?: object) => {
  return http.request<ResultTable>("post", `/account/user/listPage`, {
    data
  });
};

//记录删除
export const deleteHandoverRecord = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/delete/handoverRecord`, {
    data
  });
};

//记录分页查询
export const queryHandoverRecord = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/handover/page/handoverRecord`, {
    data
  });
};

//记录更新
export const updateHandoverRecord = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/update/handoverRecord`, {
    data
  });
};

// 主办工程师签核记录
export const querySignList = (params?: object) => {
  return http.request("get", `/operation/api/v1/handover/list/handoverSignTask`, {
    params
  });
};

// 交接班数据提交
export const handoverSubmit = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/data/submit`, {
    data
  });
};

// 签核流程信息
export const handoverFlow = (params?: object) => {
  return http.request("get", `/operation/api/v1/handover/list/handoverTask`, {
    params
  });
};
// 接班确认
export const handoverConfirm = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/confirm`, {
    data
  });
};
// 签核
export const handoverSign = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/sign`, {
    data
  });
};

// 查询taskId 信息
export const queryTaskInfo = (data?: object) => {
  return http.request("post", `/operation/api/v1/handover/query/sign/task`, {
    data
  });
};

// 交接是否可以修改提交
export const queryCanCommit = (params?: object) => {
  return http.request("get", `/operation/api/v1/handover/canCommit`, {
    params
  });
};

// 查询交接班记录详情
export const queryHandoverData = (params?: object) => {
  return http.request("get", `/operation/api/v1/handover/queryHandoverData`, {
    params
  });
};

// 导出记录
export const exportHandoverList = (data?: object) => {
  return http.request(
    "post",
    `/operation/api/v1/handover/data/export`,
    {
      data
    },
    {
      responseType: "arraybuffer"
    }
  );
};

// 值班管理|工作排班查询
export const queryMonthSchedule = (data?: object) => {
  return http.request("post", `/operation/api/v1/schedule/monthView/query`, {
    data
  });
};

// 值班管理|假期查询
export const queryMonthHoliday = (data?: object) => {
  return http.request("post", `/operation/api/v1/schedule/holiday/query`, {
    data
  });
};

// 值班管理|导入
export const importSchedule = (data: object) => {
  return http.request(
    "post",
    `/operation/api/v1/schedule/data/import`,
    {
      data
    },
    {
      headers: {
        noLoading: true,
        "content-type": "application/x-www-form-urlencoded"
      }
    }
  );
};
export const queryShiftRule = (data?: object) => {
  return http.request("post", `/operation/api/v1/schedule/shiftRule/query`, {
    data
  });
};
